<html>
<head><meta charset="utf-8"><title>rustfix unused imports · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html">rustfix unused imports</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216030617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030617">(Nov 08 2020 at 23:16)</a>:</h4>
<p>It seems that the implementation in rustc to allow rustfix to remove unused imports was in <a href="https://github.com/rust-lang/rust/issues/56645">#56645</a>. But there's a limitation in the JSON error format that prevents rustfix from applying the suggestions in all cases (<a href="https://github.com/rust-lang/rust/issues/53934">#53934</a>). However, I ran <code>cargo fix</code> using a master version of rustc (because I'm working on clippy) and none of the imports were fixed. The warnings in this case are:</p>
<div class="codehilite"><pre><span></span><code>warning: unused import: `crate::utils::paths`
 --&gt; clippy_lints/src/assertions_on_constants.rs:2:5
  |
2 | use crate::utils::paths;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `match_function_call`
 --&gt; clippy_lints/src/assertions_on_constants.rs:4:36
  |
4 |     is_direct_expn_of, is_expn_of, match_function_call, match_panic_call, snippet_opt, span_lint_and_help,
  |                                    ^^^^^^^^^^^^^^^^^^^

warning: unused imports: `match_def_path`, `paths`
 --&gt; clippy_lints/src/attrs.rs:4:47
  |
4 |     first_line_of_span, is_present_in_source, match_def_path, match_panic_def_id, paths, snippet_opt, span_lint,
  |                                               ^^^^^^^^^^^^^^                      ^^^^^

warning: unused imports: `BEGIN_PANIC_FMT`, `BEGIN_PANIC`
 --&gt; clippy_lints/src/fallible_impl_from.rs:1:27
  |
1 | use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT};
  |                           ^^^^^^^^^^^  ^^^^^^^^^^^^^^^

warning: unused imports: `BEGIN_PANIC_FMT`, `BEGIN_PANIC`, `match_def_path`
 --&gt; clippy_lints/src/implicit_return.rs:2:33
  |
2 |     fn_has_unsatisfiable_preds, match_def_path, match_panic_def_id,
  |                                 ^^^^^^^^^^^^^^
3 |     paths::{BEGIN_PANIC, BEGIN_PANIC_FMT},
  |             ^^^^^^^^^^^  ^^^^^^^^^^^^^^^

warning: unused imports: `match_function_call`, `paths`
 --&gt; clippy_lints/src/panic_unimplemented.rs:1:51
  |
1 | use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, match_panic_call, paths, span_lint};
  |                                                   ^^^^^^^^^^^^^^^^^^^                    ^^^^^

warning: 6 warnings emitted
</code></pre></div>
<p>Why isn't it working?</p>



<a name="216030629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030629">(Nov 08 2020 at 23:17)</a>:</h4>
<p><span class="user-mention" data-user-id="307537">@Camelid</span> are you sure they're marked as <code>MachineApplicable</code>?</p>



<a name="216030635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030635">(Nov 08 2020 at 23:17)</a>:</h4>
<p>you can apply suggestions that aren't with <code>__CARGO_FIX_YOLO=1</code></p>



<a name="216030682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030682">(Nov 08 2020 at 23:18)</a>:</h4>
<p>Nope, that env var didn't do anything</p>



<a name="216030696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030696">(Nov 08 2020 at 23:18)</a>:</h4>
<p>And also the PR that introduced this (<a href="https://github.com/rust-lang/rust/issues/56645">#56645</a>) showed an example of using <code>cargo fix</code> to auto-remove the imports</p>



<a name="216030706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030706">(Nov 08 2020 at 23:18)</a>:</h4>
<p>not sure then, sorry</p>



<a name="216030713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030713">(Nov 08 2020 at 23:19)</a>:</h4>
<p>Yeah, it's kind of weird</p>



<a name="216030724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030724">(Nov 08 2020 at 23:19)</a>:</h4>
<p>Perhaps <span class="user-mention silent" data-user-id="121055">Pietro Albini</span> will know, since they're the one who implemented that PR.</p>



<a name="216030769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030769">(Nov 08 2020 at 23:20)</a>:</h4>
<p>(I wish there were a way to ping with low priority or something)</p>



<a name="216030773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030773">(Nov 08 2020 at 23:20)</a>:</h4>
<p>haha you can go ahead and ping</p>



<a name="216030887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030887">(Nov 08 2020 at 23:22)</a>:</h4>
<p>Ok :)</p>



<a name="216030892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216030892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216030892">(Nov 08 2020 at 23:22)</a>:</h4>
<p><span class="user-mention" data-user-id="121055">@Pietro Albini</span> do you know why this isn't working?</p>



<a name="216031011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031011">(Nov 08 2020 at 23:25)</a>:</h4>
<p>oooh</p>



<a name="216031018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031018">(Nov 08 2020 at 23:26)</a>:</h4>
<p>this is a <em>deep</em> rabbit hole</p>



<a name="216031055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031055">(Nov 08 2020 at 23:26)</a>:</h4>
<p>you sure you want to go down it? <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="216031064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031064">(Nov 08 2020 at 23:27)</a>:</h4>
<p>Perhaps a little ways down :)</p>



<a name="216031090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031090">(Nov 08 2020 at 23:27)</a>:</h4>
<p>so, we need to do multiple replaces in order for rustfixing unused imports to work</p>



<a name="216031132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031132">(Nov 08 2020 at 23:28)</a>:</h4>
<p>but that's currently impossible in the current json output representation</p>



<a name="216031141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031141">(Nov 08 2020 at 23:28)</a>:</h4>
<p>Hmm, why multiple replaces?</p>



<a name="216031143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031143">(Nov 08 2020 at 23:28)</a>:</h4>
<p>we had like a full session during 2019 all hands but we were not able to get to a definitive solution for it</p>



<a name="216031151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031151">(Nov 08 2020 at 23:28)</a>:</h4>
<p>And also, why did <code>cargo fix</code> work in your PR?</p>



<a name="216031179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031179">(Nov 08 2020 at 23:29)</a>:</h4>
<p>for example, in<br>
use foo::{<strong>bar, </strong>baz<strong>, foobar</strong>};<br>
both the bold parts need to be removed, and those are two separate replaces</p>



<a name="216031181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031181">(Nov 08 2020 at 23:29)</a>:</h4>
<p>Hmm, I see.</p>



<a name="216031228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031228">(Nov 08 2020 at 23:30)</a>:</h4>
<p>it was supposed to work when there was only one part to remove</p>



<a name="216031230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031230">(Nov 08 2020 at 23:30)</a>:</h4>
<p>but that was a while ago when I implemented the PR</p>



<a name="216031237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031237">(Nov 08 2020 at 23:30)</a>:</h4>
<p>dunno why that's not working for single parts to remove right now</p>



<a name="216031251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031251">(Nov 08 2020 at 23:31)</a>:</h4>
<p>Hmm</p>



<a name="216031273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031273">(Nov 08 2020 at 23:31)</a>:</h4>
<p>We could just try to fix one import at a time :)</p>



<a name="216031360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031360">(Nov 08 2020 at 23:33)</a>:</h4>
<p>that would emit a warning for each import you want to report</p>



<a name="216031378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031378">(Nov 08 2020 at 23:33)</a>:</h4>
<p>it would regress the compiler errors UX a lot</p>



<a name="216031387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031387">(Nov 08 2020 at 23:34)</a>:</h4>
<p>also cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span> on this, as a throwback to that all hands session</p>



<a name="216031430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031430">(Nov 08 2020 at 23:34)</a>:</h4>
<p>Yeah, I didn't mean that way. I realized that I don't know what the error format looks like currently, so I should look at that first before I make any suggestions <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="216031444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031444">(Nov 08 2020 at 23:35)</a>:</h4>
<p>it's basically a json dump of the output you see</p>



<a name="216031453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031453">(Nov 08 2020 at 23:35)</a>:</h4>
<p>the issue is, the json format supports multiple replacements</p>



<a name="216031514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031514">(Nov 08 2020 at 23:36)</a>:</h4>
<p>but there is no way to tell if it's a single suggestion with multiple replacements (like in this case) or multiple suggestions with a single replacement like this:</p>
<p>use std::collections::HashMap;<br>
use hashbrown::HashMap;</p>



<a name="216031524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031524">(Nov 08 2020 at 23:36)</a>:</h4>
<p>I see</p>



<a name="216031534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031534">(Nov 08 2020 at 23:36)</a>:</h4>
<p>at the moment all the tools interpret multiple replacements as multiple suggestions with a single replacement each</p>



<a name="216031553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031553">(Nov 08 2020 at 23:37)</a>:</h4>
<p>so we can't implement this without either silently breaking all the tools, or implementing a json format v2</p>



<a name="216031575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031575">(Nov 08 2020 at 23:38)</a>:</h4>
<p>Could we instead have a single suggestion that replaces the whole line with a fixed line? Or something like that?</p>



<a name="216031626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216031626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Pietro Albini <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216031626">(Nov 08 2020 at 23:39)</a>:</h4>
<p>iirc that messed up some things, but I don't remember exactly what</p>



<a name="216034246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216034246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216034246">(Nov 09 2020 at 00:45)</a>:</h4>
<p>Yeah, it's been in my queue to actually address this for ages. I might be able to get to it in the short term, depending on some personal changes.</p>



<a name="216034252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216034252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216034252">(Nov 09 2020 at 00:45)</a>:</h4>
<p>I really want to make this work better.</p>



<a name="216039781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/rustfix%20unused%20imports/near/216039781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/rustfix.20unused.20imports.html#216039781">(Nov 09 2020 at 03:03)</a>:</h4>
<p>Thanks for making so many diagnostics better!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>